package cn.itcast.up.model.matchtag

import cn.itcast.up.model.base.BaseModel
import org.apache.spark.sql.DataFrame

/**
  * 使用模型基类进行标签计算
  */
object Gender2Model extends BaseModel{
  import spark.implicits._
  /**
    * 设置当前应用的名字
    *
    * @return
    */
  override def setAppName(): String = "Gender2Model"

  /**
    * 设置4级标签ID
    *
    * @return
    */
  override def setFourTagID(): Int = 472

  /**
    *
    * @param hbaseDF HBase数据源
    * @param fiveDF 规则数据
    * @return 最终的计算结果:userid, tagIds
    */
  override def computeTagIds(hbaseDF: DataFrame, fiveDF: DataFrame): DataFrame = {

    //使用HBASEDF和fiveDF进行关联
    hbaseDF.join(fiveDF, hbaseDF.col("gender") === fiveDF.col("rule"))
      .select(hbaseDF.col("id").as("userid"), fiveDF.col("id").as("tagIds"))
  }


  def main(args: Array[String]): Unit = {
    executeCompute()
  }


}
